home *** CD-ROM | disk | FTP | other *** search
/ Aminet 32 / Aminet 32 (1999)(Schatztruhe)[!][Aug 1999].iso / Aminet / comm / tcp / hserv.lha / hserv / cgi-bin / whois.rexx < prev   
OS/2 REXX Batch file  |  1999-05-24  |  1KB  |  51 lines

  1. /*whois.rexx 1.0*/
  2.  
  3. signal on break_c
  4.  
  5. say "Content-type: text/html";say
  6. say "<html><head><title>Whois</title></head><BODY>"
  7.  
  8. l="rexxsupport.library";if ~show("L",l) then;if ~addlib(l,0,-30) then call err "can't find" l
  9. l="rmh.library";if ~show("L",l) then;if ~addlib(l,0,-30) then call err "can't find" l
  10. l="rxsocket.library";if ~show("L",l) then;if ~addlib(l,0,-30) then call err "can't find" l
  11.  
  12. parse arg a +11 who
  13.  
  14. select
  15.     when a~="searchText=" then call err "bad request"
  16.     when who=="" then call err "You must give me something to search for!"
  17.     otherwise nop
  18. end
  19.  
  20. s=socket("INET","STREAM")
  21. if s<0 then call err "no socket"
  22.  
  23. remote.addraddr=resolve("rs.internic.net")
  24. if remote.addraddr=="-1" then call err "can't resolve rs.internic.net<BR>(Are you online?)"
  25. remote.addrport=43
  26. if connect(s,"REMOTE")<0 then call err "can't connect"
  27.  
  28. req="WHOIS" who||d2c(10)||d2c(13)
  29. if send(s,req)~=length(req) then call err "send error"
  30.  
  31. say "<CENTER><STRONG>Whois results for '"who"'</STRONG></CENTER><BR><HR><PRE>"
  32. r=1
  33. do while r>0
  34.     r=recv(s,"BUF",256)>0
  35.     if r>0 then call writech("STDOUT",buf)
  36. end
  37. if r<0 then call err "recv error"
  38. else say "</PRE></BODY></HTML>"
  39. exit
  40.  
  41. break_c:
  42.     say
  43.     call err "break"
  44.     exit
  45.  
  46. err:
  47. parse arg msg
  48.     say "<BR><h1><strong>Sorry, internal script error:<BR>"msg"</strong></h1></body>"
  49.     say "</html>"
  50.     exit
  51.